Dynamically controlled auto-ranging current sense circuit

ABSTRACT

Embodiments relate to sensing a current provided by a power supply circuit. The current sensing circuit includes a sense transistor for sensing the current provided by a main transistor, a driver for controlling a bias provided to the sense transistor and the main transistor, and a sense resistor for converting the sensed current to a voltage value. Moreover, the current sensing circuit includes a controller that modifies at least one of: (a) a resistance of the main transistor by adjusting the bias voltage provided by the driver, (b) a gain ratio between a load current and a sensing current by adjusting a number of individual devices that are active in the sense transistor, and (c) a resistance of the sense resistor.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of co-pending U.S. application Ser.No. 16/734,017, filed Jan. 3, 2020, which is incorporated by referencein its entirety.

BACKGROUND 1. Field of the Disclosure

The present disclosure relates a circuit for a current sense circuit andmore specifically to a dynamic auto-ranging current sensing circuit.

2. Description of the Related Arts

Current sensing is used in a wide variety of application includingbattery life indicators, battery charger control, over currentprotection, circuits supervision, current and voltage regulation, groundfault detection, proportional solenoid control, etc. Current sensecircuits suffer from many sources of error including mismatch betweenthe power and sense transistors, offset and gain limit in amplifiers,process variation of sense resistors, and input referred noise at largesense ratios. For example, for high load currents, threshold voltages(VT), channel width/length ratios (W/L), and metallization mismatchesbetween power and sense transistors become a significant source of errorfor current sense circuits. Moreover, for low load currents, amplifieroffset and the limit in the gain of the amplifier can cause asignificant error in the sensing of the load current.

SUMMARY

Embodiments relate to sensing a current provided by a power supplycircuit. The current sensing circuit includes a sense transistor forsensing the current provided by a main transistor, a driver forcontrolling a bias provided to the sense transistor and the maintransistor, and a sense resistor for converting the sensed current to avoltage value. The current sensing circuit includes a controller thatmodifies at least one of (a) a resistance of the main transistor byadjusting the bias voltage provided by the driver, (b) a gain ratiobetween a load current and a sensing current by adjusting a number ofindividual devices that are active in the sense transistor, and (c) aresistance of the sense resistor.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a high-level diagram of an electronic device, according to oneembodiment.

FIG. 2 is a circuit diagram illustrating a current sense circuit,according to one embodiment.

FIG. 3 is a circuit diagram, illustrating a dynamic auto-ranging currentsense circuit, according to one embodiment.

FIG. 4 is a circuit diagram illustrating the driver of the dynamicauto-ranging current sense circuit of FIG. 3, according to oneembodiment.

FIG. 5A is a circuit diagram illustrating a dynamic current sensecircuit for the dynamic auto-ranging current sense circuit of FIG. 3,according to one embodiment.

FIG. 5B is a circuit diagram illustrating a dynamic current sensecircuit for the dynamic auto-ranging current sense circuit of FIG. 3,according to a second embodiment.

FIG. 5C is a circuit diagram illustrating a dynamic current sensecircuit for the dynamic auto-ranging current sense circuit of FIG. 3,according to a third embodiment.

FIG. 5D is a circuit diagram illustrating a digital encoder to generatethe sense control signal for controlling the dynamic current sensecircuit, according to one embodiment.

FIG. 5E is a plan view illustrating a layout of the sense transistorsand the main transistor, according to one embodiment.

FIG. 6 is a circuit diagram illustrating a variable sense resistor forthe dynamic auto-ranging current sense circuit of FIG. 3, according toone embodiment.

FIG. 7 is a circuit diagram illustrating a controller circuit for thedynamic auto-ranging current sense circuit of FIG. 3, according to oneembodiment.

FIG. 8A is a flowchart illustrating a method for dynamically adjustingthe sensitivity of the sense circuit, according to one embodiment.

FIG. 8B is a flowchart illustrating a process for adjusting thesensitivity of the sense circuit when the count of the up/down counterincreases, according to one embodiment.

FIG. 8C is a flowchart illustrating a process for adjusting thesensitivity of the sense circuit when the count of the up/down counterdecreases, according to one embodiment.

The figures depict, and the detail description describes, variousnon-limiting embodiments for purposes of illustration only.

DETAILED DESCRIPTION

Reference will now be made in detail to embodiments, examples of whichare illustrated in the accompanying drawings. In the following detaileddescription, numerous specific details are set forth in order to providea thorough understanding of the various described embodiments. However,the described embodiments may be practiced without these specificdetails. In other instances, well-known methods, procedures, components,circuits, and networks have not been described in detail so as not tounnecessarily obscure aspects of the embodiments.

Embodiments relate to a dynamically controlled auto-ranging currentsensing circuit that dynamically adjusts the sensitivity based on thecurrent level being provided to a load. The dynamically controlledauto-ranging current sensing circuit modifies a bias voltage provided bya driver to a main transistor and a sense transistor, a current gainbetween a load current and a sensing current, and a resistance of asensing resistor that generates a voltage proportional to the currentgenerated by the sense transistor. Moreover, the dynamically controlledauto-ranging current sensing circuit includes a low-resolutionanalog-to-digital converter (ADC) for converting the voltage generatedby the sense transistor to a digital value. The digital value providedby the low-resolution ADC is adjusted based on the current gain, and theresistance of the sensing resistor to match the performance of ahigh-resolution ADC.

Exemplary Electronic Device

Embodiments of electronic devices, user interfaces for such devices, andassociated processes for using such devices are described. In someembodiments, the device is a portable communications device, such as amobile telephone, that also contains other functions, such as personaldigital assistant (PDA) and/or music player functions. Exemplaryembodiments of portable multifunction devices include, withoutlimitation, the iPhone®, iPod Touch®, Apple Watch®, and iPad® devicesfrom Apple Inc. of Cupertino, Calif. Other portable electronic devices,such as wearables, laptops or tablet computers, are optionally used. Insome embodiments, the device is not a portable communications device,but is a desktop computer or other computing device that is not designedfor portable use. In some embodiments, the disclosed electronic devicemay include a touch sensitive surface (e.g., a touch screen displayand/or a touch pad). An example electronic device described below inconjunction with FIG. 1 (e.g., device 100) may include a touch-sensitivesurface for receiving user input. The electronic device may also includeone or more other physical user-interface devices, such as a physicalkeyboard, a mouse and/or a joystick.

Figure (FIG. 1 is a high-level diagram of an electronic device 100,according to one embodiment. Device 100 may include one or more physicalbuttons, such as a “home” or menu button 104. Menu button 104 is, forexample, used to navigate to any application in a set of applicationsthat are executed on device 100. In some embodiments, menu button 104includes a fingerprint sensor that identifies a fingerprint on menubutton 104. The fingerprint sensor may be used to determine whether afinger on menu button 104 has a fingerprint that matches a fingerprintstored for unlocking device 100. Alternatively, in some embodiments,menu button 104 is implemented as a soft key in a graphical userinterface (GUI) displayed on a touch screen.

In some embodiments, device 100 includes touch screen 150, menu button104, push button 106 for powering the device on/off and locking thedevice, volume adjustment buttons 108, Subscriber Identity Module (SIM)card slot 110, head set jack 112, and docking/charging external port124. Push button 106 may be used to turn the power on/off on the deviceby depressing the button and holding the button in the depressed statefor a predefined time interval; to lock the device by depressing thebutton and releasing the button before the predefined time interval haselapsed; and/or to unlock the device or initiate an unlock process. Inan alternative embodiment, device 100 also accepts verbal input foractivation or deactivation of some functions through microphone 113. Thedevice 100 includes various components including, but not limited to, amemory (which may include one or more computer readable storagemediums), a memory controller, one or more central processing units(CPUs), a peripherals interface, an RF circuitry, an audio circuitry,speaker 111, microphone 113, input/output (I/O) subsystem, and otherinput or control devices. Device 100 may include one or more imagesensors 164, one or more proximity sensors 166, and one or moreaccelerometers 168. The device 100 may include components not shown inFIG. 1.

Device 100 is only one example of an electronic device, and device 100may have more or fewer components than listed above, some of which maybe combined into a component or have a different configuration orarrangement. The various components of device 100 listed above areembodied in hardware, software, firmware or a combination thereof,including one or more signal processing and/or application specificintegrated circuits (ASICs). Device 100 may include one or more currentsense circuits described herein.

Example Current Sense Circuit

FIG. 2 is a circuit diagram illustrating current sense circuit 200,according to one embodiment. The current sense circuit 200 includes maintransistor Mp 220 for driving a load current Iload to a load 250, and asense transistor Msense 210 for providing a sense current Isense thathas an amplitude based on the load current Iload to a sense resistorRsense 270. The sense current Isense may be proportional to the loadcurrent Iload. The relationship between the sense current Isense and theload current Iload may be based on a size ratio between the sensetransistor Msense 210 and the main transistor Mp 220. The output of themain transistor Mp 220 may be coupled to a capacitor C 260.

The current sense circuit 200 further includes a driver 230 thatprovides a driving voltage to the main transistor Mp 220 and the sensetransistor Msense 210. The driver 230 is coupled to the gate of the maintransistor Mp 220 and the gate of the sense transistor Msense 210. Insome embodiments, the driver 230 provides a bias voltage to the gate ofthe main transistor Mp 220 and the gate of the sense transistor Msense210. In yet other embodiments, the driver 230 is a low resolutiondigital to analog converter (DAC) that receives a digital control signaland generates the analog voltage provided to the gate of the maintransistor Mp 220 and the gate of the sense transistor Msense 210.

The current sense circuit 200 additionally includes an amplifiertransistor Tamp 280 that is controlled by a sense amplifier 240. Theamplifier transistor Tamp 280 is coupled between the sense transistorMsense 210 and the sense resistor Rsense 270. The sense amplifier 240includes a first input terminal that is coupled to an output of the maintransistor Mp 220, and a second input terminal that is coupled to anoutput of the sense transistor Msense 210. The output of the senseamplifier 240 is then coupled to a gate of the amplifier transistor Tamp280. The sense amplifier forces the voltage at the output of the sensetransistor Msense 210 to be the voltage at the output of the maintransistor Mp 220. Because the gate of the main transistor Mp 220 andthe gate of the sense transistor Msense 210 are connected together, thesense amplifier 240 forces the gate-to-source voltage (Vgs) of the senseamplifier Msense 210 to be the Vgs of the main transistor Mp 220.

The current sense circuit 200 further includes a digital-to-analogconverter (ADC) 290 coupled to the sense resistor Rsense 270. The ADC290 senses the voltage at one terminal of the sense resistor Rsense 270and converts the sensed voltage to a digital value D<N_(high_res):1>.Since the value of the sense resistor Rsense 270 is known, the amplitudeof the sense current Isense can be determined by dividing the voltageVout by the resistance Rsense 270. Moreover, since the size ratiobetween the size of the main transistor Mp 220 and the size of the sensetransistor Msense 210 is known, the load current Iload can be determinedby multiplying the sense current Isense by this ratio. In the currentsense circuit 200 of FIG. 2, the ADC has a high resolution to enable anaccurate reading of the voltage Vout and thus, an accurate sensing ofthe load current Iload.

However, in the current sense circuit 200, errors may be introducedduring the sensing process. For instance, the voltage (Vp) at the loadside is equal to:Vp=V _(DD) −ΔVp, where ΔVp=l _(load)(Ron _(p) +Rm _(p))  (1)and the voltage (Vs) at the sense side is equal to:Vs=V _(DD) −ΔVs, where ΔVs=l _(sense)(Ron _(s) +Rm _(s))  (2)where Ron_(p) and Ron_(s) are the on resistances of the main transistorMp 220 and the sense transistor Msense 210, and Rm_(p) and Rm_(s) aremetallization resistances of the main transistor Mp 220 and the sensetransistor Msense 210.

Moreover, the relationship between Vs and Vp can be expressed using thefollowing equation:A _(v)(Vp−Vs+V _(off))=Vs  (3)where A_(v) is the gain of the sense amplifier 240 and V_(off) is theoffset of the sense amplifier 240. Thus, substituting Vs and Vp, weobtain:

$\begin{matrix}{{A_{v}\left( {V_{DD} - {\Delta\;{Vp}} + V_{off}} \right)} = {\left( {A_{v} + 1} \right)\left( {V_{DD} - {\Delta\;{Vs}}} \right)}} & (4) \\{{\Delta\;{Vs}} = {{\Delta\;{{Vp} \cdot \frac{A_{v}}{A_{v} + 1}}} - {V_{off} \cdot \frac{A_{v}}{A_{v} + 1}} + {V_{DD} \cdot \frac{1}{A_{v} + 1}}}} & (5)\end{matrix}$Therefore:

$\begin{matrix}{{I_{sense} = {{I_{load} \cdot \frac{{Ron}_{p} + {Rm_{p}}}{{Ron}_{s} + {Rm_{s}}} \cdot \frac{A_{v}}{A_{v} + 1}} + {\frac{{- V_{off}} + {V_{dd}/A_{v}}}{{Ron_{s}} + {Rm_{s}}} \cdot \frac{A_{v}}{A_{v} + 1}}}}\mspace{79mu}{and}} & (6) \\{V_{out} = {{I_{load} \cdot \frac{{Ron}_{p} + {Rm_{p}}}{{Ron}_{s} + {Rm_{s}}} \cdot \frac{A_{v}}{A_{v} + 1} \cdot R_{sense}} + {\frac{{- V_{off}} + {V_{dd}/A_{v}}}{{Ron_{s}} + {Rm_{s}}} \cdot \frac{A_{v}}{A_{v} + 1} \cdot R_{sense}}}} & (7)\end{matrix}$As a result, both the sense current (Isense) and the sense voltage(Vout) are prone to errors due to a limited amount of gain of the senseamplifier 240 and an offset in the sense amplifier 240.Example Dynamic Auto-Ranging Current Sense Circuit

FIG. 3 is a circuit diagram, illustrating dynamic auto-ranging currentsense circuit 300, according to one embodiment. The dynamic auto-rangingcurrent sense circuit 300 may include, among other components, maintransistor Mp 220 for driving a load current Iload to a load 250, and asense transistor Msense 310 for providing a sense current Isense thathas an amplitude based on the load current Iload to a sense resistorRsense 370. The dynamic auto-ranging current sense circuit 300 furtherincludes a driver 330 that provides a driving voltage to the maintransistor Mp 220 and the sense transistor Msense 310. The driver 330 iscoupled to the gate of the main transistor Mp 220 and the gate of thesense transistor Msense 310. Additionally, the dynamic auto-rangingcurrent sense circuit 300 includes a low resolution ADC 380 thatconverts the analog voltage at the sense resistor Rsense 370 to adigital value D<N_(low_res):1>.

Controller 390 is a circuit that controls the driver 330, sensetransistor Msense 310, and the sense resistor Rsense 370. The controller390 receives as an input the voltage at an output of the main transistorMp 220 and generates control signals for the driver 330, the sensetransistor Msense 310, and the sense resistor Rsense 370. In particular,the controller 390 generates a control signal Dcontrol to control thedriver 330, a control signal Scontrol to control the sense transistorMsense 310, and a control signal Rcontrol to control the sense resistorRsense 370. The controller 390 is described in more detail below inconjunction with FIG. 7.

The driver 330 provides a bias voltage Vbias to the main transistor Mp220 and the sense transistor Msense 310. The driver 330 receives as aninput control signal Dcontrol. Moreover, the output 335 of the driver330 is coupled to the sense transistor Msense 310 and the maintransistor Mp 220. By changing the bias voltage Vbias, the on resistance(Rdson) of the main transistor Mp 220 and the on resistance (Rdson) ofthe sense transistor Msense 310 is controlled. Adjusting Rdson of themain transistor Mp 220 and the sense transistor Msense 310 does notchange the value of sense voltage Vout but improves sense accuracy.Increasing Rdson allows for bigger voltage drop at lower load currentsand keeps the signal level high relative to offset and noise. That is,adjusting Rdson adjusts the sense voltage signal amplitude across themain transistor Mp 220 and the sense transistor Msense 310. At largervoltage drops across the main transistor Mp 220 and the sense transistorMsense 310, sensing is less susceptible to offset and noise.

In some embodiments, as the drain-to-source voltage (Vds) of the maintransistor Mp 220 decreases, Rdson of the main transistor Mp 220 andRdson of the sense transistor Msense 310 are increased. For instance, ifthe Vds of the main transistor Mp 220 decreases below a first thresholdVds value (VTH_LOW) (e.g., VDS_LOW=30 mV), Rdson is increased to keepVds higher than VTH_LOW. Rdson of the main transistor Mp 220 may beincreased by lowering the gate-to-source voltage (Vgs) of the maintransistor Mp 220.

In some embodiments, as Vds of the main transistor Mp 220 increases,Rdson of the main transistor Mp 220 and the sense transistor Msense 310are decreased. For instance, if the Vds of the main transistor Mp 220increases above a second threshold Vds value (VTH_HIGH) (e.g.,VTH_HIGH=60 mV), Rdson is decreased to keep Vds lower than VTH_HIGH.Rdson of the main transistor Mp 220 may be decreased by increasing theVgs of the main transistor Mp 220.

In some embodiments, Vgs of the main transistor Mp 220 and the sensetransistor Msense 310 provided by the driver 330 is increased ordecreased in discrete steps. The driver 330 is described below in moredetail in conjunction with FIG. 4.

The size of the sense transistor Msense 310 is controlled by controller390. In some embodiments, the size of the sense transistor Msense 310 isexpressed as a ratio (W/L) between the channel width (W) and the channellength (L) of the sense transistor Msense 310. The size of the sensetransistor Msense 310 may be controlled by activating or deactivatingindividual sense devices that are connected in parallel. In someembodiments, each of the sense devices of the sense transistor Msense310 have the same length. As such, an effective width of the sensetransistor Msense 310 can be increased or decreased by activating ordeactivating a subset of devices. By increasing or decreasing the sizeof the sense transistor Msense 310, the ratio between the sense currentIsense and the load current Iload (sense current ratio) can be increasedor decreased.

In some embodiments, as the load current Iload decreases, the sensecurrent ratio is decreased to maintain the output voltage Vout within aset range. For instance, if the load current Iload reaches a firstthreshold value, the sense current ratio is decreased. In someembodiments, Vds of the main transistor Mp 220 is used as a proxy todetermine whether the load current Iload has reached the first thresholdvalue. For instance, if Vds of the main transistor Mp 220 decreasesbelow VTH_LOW, the sense ratio is decreased. Changing the sense currentratio is advantageous, among other reasons, because the dynamic rangeand noise performance of the dynamic auto-ranging current sense circuit300 can be enhanced. Lower sense current ratio helps to decrease inputreferred noise at low current conditions. However, if the sense currentratio is lowered at high current conditions, power consumption isincreased due to increased sense current.

In some embodiments, as the load current Iload increases, the sensecurrent ratio is increased to maintain the output voltage Vout withinthe set range. For instance, if the load current Iload reaches a secondthreshold value, the sense current ratio is increased; and if Vds of themain transistor Mp 220 increases above VTH_HIGH, the sense current ratiois increased. The sense current ratio may be increased or decreased indiscrete steps. The variable size sense transistor Msense 310 isdescribed below in more detail in conjunction with FIG. 5.

The resistance (R) of the sense resistor Rsense 370 is controlled by thecontroller 390. The sense resistor Rsense may include a resistor ladderwith multiple resistors in series. The resistance of the sense resistorRsense 370 may be controlled by selecting a node in the resistanceladder and connecting the selected node to ground. By increasing ordecreasing the resistance R of the sense resistor Rsense 370, the valueof the sense voltage Vout can be increased or decreased accordingly.

In some embodiments, as the load current Iload decreases, the resistanceR of the sense resistor Rsense 370 is increased to maintain the outputvoltage Vout within a set range. For instance, if the load currentreaches a first threshold value, the resistance of the sense resistorRsense 370 is increased. In some embodiments, Vds of the main transistorMp 220 is used as a proxy to determine whether the load current Iloadhas reached the first threshold value. For instance, if Vds of the maintransistor Mp 220 decreases below VTH_LOW, the resistance R of the senseresistor Rsense 370 is increased. Changing the resistance R of the senseresistor Rsense 370 is advantageous, among other reasons, because as theload current Iload changes, and thus the sense current Isense changes,the output voltage Vout is kept within the dynamic range of the ADC 380,allowing the use of a low resolution ADC.

In some embodiments, as the load current Iload increases, the resistanceR of the sense resistor Rsense 370 is decreased to maintain the outputvoltage Vout within the set range. For instance, if the load currentreaches a second threshold value, the resistance of the sense resistorRsense 370 is decreased. For example, if Vds of the main transistor Mp220 increases above VTH_HIGH, the resistance R of the sense resistorRsense 370 is decreased. The resistance R of the sense resistor Rsense370 may be increased or decreased in discrete steps. The variable senseresistor Rsense 370 is described below in more detailed in conjunctionwith FIG. 6.

In some embodiments, adjusting Rdson of the main transistor Mp 220,adjusting the resistance R of the sense resistor Rsense 370, andadjusting the sense current ratio are performed independently. Theadjustment of each of Rdson, resistance R and the sense current ratiocan be associated with different current thresholds.

The analog-to-digital converter (ADC) 380 is coupled to the senseresistor Rsense 370 and converts the voltage Vout at the sense resistorRsense 370 to a digital value D<N_(low_res):1>. In some embodiments, theADC 380 has a low resolution. For instance, the resolution of ADC 380 islower than the resolution of ADC 290 of the current sense circuit 200 ofFIG. 2. Using a low resolution ADC reduces the area occupied by the ADC.

FIG. 4 is a circuit diagram illustrating the driver 330 of the dynamicauto-ranging current sense circuit 300 of FIG. 3, according to oneembodiment. The driver 330 may include, among other components, a chainof diode connected transistors 410A through 410N connected in series anda current source Ibias 415. The current source Ibias 415 and the chainof diode connected transistors 410A through 410N are connected between afirst terminal 420 and a second terminal 430. In some embodiments, thefirst terminal 420 is a power supply terminal (Vdd). Moreover, thesecond terminal 430 may be connected to an output terminal of the maintransistor Mp 220 of FIG. 3. The gate of each of a subset of diodeconnected transistors 410A through 410N is connected to the secondterminal 430 through one of switches 4 440B through 440N. In the exampleof FIG. 4, the gate of the second diode connected transistor 410B isconnected to the second terminal 430 through switch 440B, the gate ofthe (n−1)th diode connected transistor 410M is connected to the secondterminal 430 through switch 440M, and the gate of the nth diodeconnected transistor 410N is connected to the second terminal 430through switch 440N.

Each of the switches 440B through 440N is controlled by a driver controlsignal 450. In some embodiments the driver control signal 450 is thecontrol signal Dcontrol received from the controller 390. In oneembodiment, the driver control signal 450 is generated using an addressdecoder (not shown) based on a binary signal Dcontrol received from thecontroller 390.

When one of the switches 440B through 440N is closed, a source terminalof a previous diode connected transistor 410 is connected to the secondterminal, bypassing a subset of diode connected transistors 410. Forinstance, if a jth switch is closed, the source of the (j−1)th diodeconnected transistor is connected to the second terminal 430, bypassingthe jth to nth diode connected transistors. As such, the bias currentIbias is configured to flow through the first to the (j−1)th diodeconnected transistors. As a result, the output voltage (Vbias) of thedriver 330 is equal to the sum of the gate-to-source voltage (Vgs) ofthe first to the (j−1)th diode connected transistors as shown in thefollowing equation:

$\begin{matrix}{{Vbias} = {\sum\limits_{k = 0}^{({j - 1})}{VGS\_ k}}} & (8)\end{matrix}$

As such, the bias voltage Vbias provided by the driver 330 to the maintransistor Mp 220 and the sense transistor Msense 310 is controlled bycontrolling the number of diode connected transistors 410 the biascurrent Ibias flows through. That is, for a given transistor,

${Ibias} = {\frac{1}{2}\mu Cox\frac{W}{L}\left( {{Vgs} - {Vth}} \right)^{2}}$Thus, the following equation can also be derived:

$\begin{matrix}{{Vgs} = {\sqrt{\frac{2{Ibias}}{\mu Co{x\left( \frac{W}{L} \right)}}} + {Vth}}} & (9)\end{matrix}$If every diode connected transistor 410 is identical (i.e., if thechannel length and width for each of the diode connected transistors 410are equal), the value of the bias voltage Vbias would be proportional tothe number of diode connected transistors that are connected in serieswithout being bypassed by a switch 440. As such, the gate voltage of themain transistor 220 can be changed in discrete steps equal to thegate-to-source voltage (Vgs) of a single diode connected transistor 410.In some embodiments, the size of each the diode connected transistors410 are selected based on a desired step. That is, if a non-uniform stepis desired, diode connected transistors 410 with differing sizes may beused.

FIG. 5A is a circuit diagram illustrating the sense transistor Msense310 for the dynamic auto-ranging current sense circuit 300 of FIG. 3,according to one embodiment. The sense transistor Msense 310 includes aset of transistors 510A through 510M (Msense_0 through Msense_M)connected in parallel. Each of the transistors 510A through 510M areconnected between a first terminal 560 and a second terminal 570. Thefirst terminal 560 is then connected to a first terminal of the maintransistor Mp 220 and the second terminal 570 is connected to the senseamplifier 240 as shown in FIG. 3. The sense transistor Msense 310further includes a set of bias switches 520A through 520M and a set ofbypass switches 530A through 530M. At least each of a subset of thetransistors 510 is connected to a first switch from the set of biasswitches 520 and a second switch from the set of bypass switches 530.For instance, in the example of FIG. 5A, transistor 510B (Msense_1) isconnected to a bias switch 520B and a bypass switch 530B. Similarly,transistor 510C (Msense_2) is connected to a switches 520C and 530C, andtransistor 510M (Msense_M) is connected to a switches 520M and 530M.

In the example of FIG. 5A, each transistor 510 has a different size. Forinstance, each transistor 510 has a different channel width (W). Inparticular, in the example of FIG. 5A, the size of the transistorsexponentially increases with a factor of 2. That is, the firsttransistor 510A (Msense_0) has a size of W/L₀=2⁰x=1x, the secondtransistor 510B (Msense_1) has a size of W/L₁=2¹x=2x, the thirdtransistor 510C (Msense_2) has a size of W/L₂=2²x=4x, and the mthtransistor 510M (Msense_M) has a size of W/L_(M)=2^(M)x. In someembodiments, each transistor is made of multiple devices or multiplefingers having the same size. That is, each transistor 510 is made ofone or more devices or fingers having the same W/L ratio. For instance,the first transistor 510A (Msense_0) is made of a single device having a1x size, the second transistor 510B (Msense_1) is made of two deviceshaving a 1x size connected in parallel, the third transistor 510C(Msense_2) is made of four devices having a 1x size connected inparallel, and the mth transistor 510M (Msense_M).

As such, the size of the sense transistor Msense 310 can be modified bydynamically activating or deactivating one or more transistors 510. Forexample, in the embodiments of FIG. 5A, by closing a first subset ofbias switches 520, the transistors 510 corresponding to the closed biasswitches 520 are activated. Moreover, by opening a second subset of biasswitches 520, the transistors 510 corresponding to the opened biasswitches 520 are deactivated. As such, the activated transistors areconnected together, defining the size of the sense transistor Msense310.

In some embodiments, the second set of bypass switches 530 are used todeactivate a subset of transistors 510. That is, by closing a bypassswitch 530 form the set of bypass switches, the corresponding transistor510 is deactivated by connecting the gate of the correspondingtransistor 510 to the second terminal 570. In some embodiments the setof bias switches 520 and the set of bypass switches are controlled suchthat when a switch from the set of bias switches 520 is opened, thecorresponding switch from the set of bypass switches 530 is closed. Forexample, when a switch 520J of the set of bias switches 520corresponding to the jth transistor 510J is opened, the switch 530J ofthe set of bypass switches 530 corresponding to the jth transistor 510Jis closed. Moreover, the set of bias switches 520 and the set of bypassswitches are controlled such that when a switch from the set of biasswitches 520 is closed, the corresponding switch from the set of bypassswitches 530 is opened. For example, when a switch 520J of the set ofbias switches 520 corresponding to the jth transistor 510J is closed,the switch 530J of the set of bypass switches 530 corresponding to thejth transistor 510J is opened switch.

In some embodiments, the switches 520 and 530 are made usingtransistors. That is, switches 520 and 530 are transistors that can beturned on to close a connection to the gate of a transistor 510 orturned off to open a connection to the gate of a transistor 510. In someembodiments, since switches 520 and 530 are not used to drive a current,the size of the transistor used to implement switches 520 and 530 aresmaller than the size of transistors 510.

Each of the switches 520 and 530 is controlled by a sense control signal550. In some embodiments the driver control signal 450 is the controlsignal Scontrol received from the controller 390. In one embodiment, thesense control signal 550 is generated using an encoder based on thecontrol signal Scontrol received from the controller 390. FIG. 5Dillustrates one implementation of an encoder used to generate the sensecontrol signal 550.

FIG. 5B is a circuit diagram illustrating the sense transistor Msense310 for the dynamic auto-ranging current sense circuit 300 of FIG. 3,according to a second embodiment. In the embodiment of FIG. 5B, thefirst transistor 510A (Msense_0) does not have switches and is directlyconnected to Vbias. As such, the first transistor 510A cannot bedeactivated. As such, the embodiment of FIG. 5B ensures that the minimumsize of the sense transistor Msense 310 is the size of the firsttransistor 510A (Msense_0).

FIG. 5C is a circuit diagram illustrating the sense transistor Msense310 for the dynamic auto-ranging current sense circuit 300 of FIG. 3,according to a third embodiment. In the embodiment of FIG. 5C, everytransistor 510 has the same size. In other embodiments, the sensetransistor Msense 310 may include a first subset of transistors 510having a first size, and a second subset of transistors 510 having asecond size. In the example of FIG. 5C, the size of the sense transistorMsense 310 is controlled by the number of transistors 510 that areactivated, and not based on which transistor 510 is activated. As such,the transistors that are activated to be used for the sense transistorMsense 310 can be rotated to account for transistor deterioration andprocess variation. That is, the transistors that are activated can berotated to enable mismatches between different transistors to bedistributed over time. Moreover, the activated transistors are rotatedto sample different locations of the main transistor Mp 220 in terms oftemperature, stress, and the like.

In some embodiments, to control which transistor 510 is used, a digitalencoder having a scrambler is used. FIG. 5D is a circuit diagramillustrating a digital encoder 580 to generate the sense control signal550 for controlling the sense transistor Msense 310, according to oneembodiment. The digital encoder 580 may be part of the sense transistorMsense 310. Alternatively, the digital encoder 580 may be a separatemodule located in the signal path between the controller 390 and thesense transistor Msense 310. The digital encoder 580 receives, from thecontroller 390, the control signal Scontrol for controlling the sensetransistor Msense 310, and generates the sense control signal 550. Thedigital encoder 580 may include, among other components, a thermometerencoder 590 and a scrambler 595.

The thermometer encoder 590 (or unary encoder) receives a binary numbern as an input and generates an output having n bits have a first value.The binary number n is the control signal Scontrol received from thecontroller 390. In one embodiment, the thermometer encoder 590 receivesa binary number n as an input and generates an output having n onesfollowed or preceded by zeros. In another embodiment, the thermometerencoder 590 receives a binary number n as an input and generates anoutput having n zeros followed or preceded by ones. For example, if theinput has a value of 5 (i.e., 0101), the thermometer encoder 590 maygenerate an output having a value of 111110000000000 or 000000000011111.That is, an output having five 1s. In another embodiment, for an inputvalue of 5 (i.e., 0101), the thermometer encoder 590 generates an outputhaving a value of 111111111100000 or 000001111111111. That is, an outputhaving five 0s.

The scrambler 595 receives the unary encoded number from the thermometerencoder 590 and randomizes (or pseud-randomizes) the position of the 1sor 0s. The scrambler 595 does not change the number of 1s or 0s from theunary encoded number. For example, if the unary encoded value generatedby the thermometer encoder 590 is 111110000000000, the scrambler 595 mayscramble the ones to generate the output signal 001010000100101.

The scrambled signal is then used to control the sense transistor Msense310. That is, since the ones in the sense control signal 550 arescrambled, the digital encoder 580 randomizes which transistors 510 arebeing activated to achieve a desired size for the sense transistorMsense 310.

FIG. 5E is a plan view illustrating a layout of transistors 510 and themain transistor Mp 220, according to one embodiment. The main transistorMp 220 includes multiple fingers, each having a size of 1x. In addition,each of the transistors 510A through 510M have a size of 1x and areinterlaced within the set of fingers of the main transistor Mp 220. Forinstance, in the example of FIG. 5E, the main transistor Mp 220 includesmultiple fingers grouped in arrays of ten fingers. The transistors 510Athrough 510M are placed in between two arrays of fingers of the maintransistor Mp 220. For instance, the first sense transistor Msense_0510A is between a first array of ten fingers and a second array of tenfingers that are part of the main transistor Mp 220. As such, if thefingers have mismatch due to process and temperature variations, andpackage stress and the properties of these fingers shift differentlyover time, this placement of the transistors 510A through 510M reducesthe dependency of the dynamic auto-ranging current sense circuit 300 onthose process variations.

FIG. 6 is a circuit diagram illustrating the variable sense resistor 370for the dynamic auto-ranging current sense circuit 300 of FIG. 3,according to one embodiment. The variable sense resistor 370 mayinclude, among other components, a chain of resistors 610A through 620Pconnected in series between the first terminal 630 and the secondterminal 640. The first terminal 630 may be coupled to the secondterminal 570 of the sense transistor Msense 310 and the second terminal640 may be coupled to ground or second supply voltage (Vss). Moreover,the variable sense resistor 370 includes multiple switches 620A through620P. Each of the switches 620 is configured to bypass one or moreresistors when closed. When one of the switches 620A through 620P isclosed, one of the resistors 610 is connected to the second terminal6740. For instance, if a jth switch is closed, the jth resistor isconnected to the second terminal 6740, bypassing the (j+1)th to pthresistor.

Each of the switches 620 is controlled by a resistor control signal 650.In some embodiments the resistor control signal 650 is the controlsignal Rcontrol received from the controller 390. In one embodiment, theresistor control signal 650 is generated using an address decoder (notshown) based on the binary signal Rcontrol received from the controller390.

FIG. 7 is a circuit diagram illustrating the controller 390 for thedynamic auto-ranging current sense circuit 300 of FIG. 3, according toone embodiment. The controller 390 receives load voltage Vload from themain transistor Mp 220, and generates control signals Dcontrol,Scontrol, and Rcontrol for controlling the driver 330, sense transistorMsense 310, and the sense resistor Rsense 370. The controller 390 mayinclude, among other components, multiple comparators 710, an up/downcounter, and an oscillator.

Each comparator 710 compares the drain-to-source voltage (Vds) of themain transistor Mp 220 to a threshold voltage. For example, the firstcomparator 710A compares Vds to a first threshold voltage VTH_LOW, asecond comparator 710B compares Vds to the second threshold voltageVTH_HIGH, and the third comparator 710C compares Vds to a thirdthreshold voltage VTH_FAST. In some embodiments, each comparator 710receives load voltage Vload and compares Vload to a threshold voltage.As used herein, the load voltage Vload is the voltage at the sourceterminal of the main transistor Mp, wherein Vds=Vd−Vload. For example,the first comparator 710A compares Vload to a first threshold voltageVd−VTH_LOW, the second comparator 710B compares Vload to a secondthreshold voltage Vd−VTH_HIGH, and the third comparator 710C comparesVload to a third threshold voltage Vd−VTH_FAST, where Vd is the drainvoltage of the main transistor Mp 220. In some embodiments, the drainvoltage Vd of the main transistor Mp 220 is a supply voltage Vdd.

In another embodiment, each comparator 710 receives the drain voltage Vdof the main transistor Mp and the load voltage Vload and compares thedifference between Vd and Vload to a threshold voltage.

When the drain-to-source voltage (Vds=Vd−Vload) of the main transistorMp 220 is higher than VTH_LOW, the first comparator 710A outputs asignal having a first value (e.g., 0 or LO). Conversely, when Vds of themain transistor Mp 220 reaches or decreases below VTH_LOW, the firstcomparator 710A output a signal having a second value (e.g., 1 or HI).The output of the first comparator 710A is connected to the UP input ofthe up/down counter 720. When the up/down counter 720 receives a signalhaving the second value (e.g., 1 or HI) from the first comparator 710A,the up/down counter 720 increases the value of a stored count.

When Vds of the main transistor Mp 220 is lower than VTH_HIGH, thesecond comparator 710B outputs a signal having the first value (e.g., 0or LO). Conversely, when Vds of the main transistor Mp 220 reaches orincreases above VTH_HIGH, the second comparator 710B outputs a signalhaving the second value (e.g., 1 or HI). The output of the secondcomparator 710B is connected to the DOWN input of the up/down counter720. When the up/down counter 720 receives a signal having the secondvalue (e.g., 1 or HI) from the second comparator 710B, the up/downcounter 720 decreases the value of a stored count.

In some embodiments, the polarity of the comparators 710 is reverseddepending on the configuration of the up/down counter 720. For instance,if the up/down counter is configured to count up or down in response toa signal having the second value (e.g., 1 or HI), the polarity of thefirst comparator 710A or the second comparator 710B may be reversed.

Moreover, the outputs of the first comparator 710A and the secondcomparator 710B are used to generate a clock enabled signal CLK_EN toenable the up/down counter 720 and the oscillator 730. In someembodiments, the clock enabled signal CLK_EN is asserted when Vds of themain transistor Mp 220 is below VTH_LOW or above VTH_HIGH. That is,CLK_EN is asserted when Vds is outside of the voltage range <VTH_LOW,VTH_HIGH>.

When Vds of the main transistor Mp 220 is lower than VTH_FAST, the thirdcomparator 710C outputs a signal having the first value (e.g., 0 or LO).Conversely, when Vds of the main transistor Mp 220 reaches or increasesabove VTH_FAST, the third comparator 710C output a signal having thesecond value (e.g., 1 or HI). When Vds if the main transistor Mp 220exceeds VTH_FAST, the third comparator 710C sends a signal to theup/down counter 720 that causes the up/down counter to reset to aninitial value. For instance, the up/down counter 720 may reset to avalue of 0. This causes the control signals Dcontrol, Scontrol, andRcontrol to rapidly change to the lowest configuration. That is, whenVds of the main transistor Mp 220 exceeds VTH_FAST, the gate voltage ofthe main transistor Mp 220 is reset to the maximum value, the currentsense ratio of the sense transistor Msense 310 is reset to the maximumvalue, and the resistance of the sense resistor Rsense 370 is reset tothe minimum value. In some embodiments, instead of resetting the up/downcounter 720, the output of the third comparator 710C causes the count ofthe up/down counter 720 to decrease by a step larger than the count downstep triggered by the second comparator 710B. That is, the output of thethird comparator 710C causes the count of the up/down counter 720 todecrease by a step larger than one.

Example Process for Sensing Load Current

FIG. 8A is a flowchart illustrating a method for dynamically adjustingthe sensitivity of the dynamic auto-ranging current sense circuit 300,according to one embodiment. The method may include additional or fewersteps, and steps may be performed in different orders.

The controller 390, as described with reference to FIG. 3 and FIG. 7,monitors 810 the drain-to-source voltage (Vds) of the main transistor Mp220. In some embodiments, the controller 390 monitors thedrain-to-source voltage (Vds) of the main transistor Mp 220 bymonitoring the load voltage (Vload) at an output of the main transistorMp 220. The controller 390 then compares Vds to a set of thresholdvalues. For instance, the first comparator 710A of the controller 390compares 820 Vds to a first threshold voltage (VTH_LOW), the secondcomparator 710B of the controller 390 compares 830 Vds to a secondthreshold voltage (VTH_HIGH), and the third comparator 710C of thecontroller 390 compares 840 Vds to a third threshold voltage (VTH_FAST).

Based on the comparison, the controller circuit updates a value storedin the up/down counter 720. If Vds decreases below VTH_LOW, thecontroller 390 increases 825 the count stored in up/down counter 720. IfVds increases above VTH_HIGH, the controller 390 decreases 835 the countstored in the up/down counter 720. If Vds exceeds VTH_FAST, thecontroller 390 decreases 845 the count stored in the up/down counter 720by an amount larger than 1. In some embodiments, if Vds exceedsVTH_FAST, the controller 390 resets the up/down counter 720.

In some embodiments, if Vds is either below VTH_LOW or above VTH_HIGH,the controller 390 turns on oscillator 730 to generate a clock signalCLK to control the rate at which the up/down counter 720 counts up ordown. That is, as long as Vds stays below VTH_LOW, the controller 390decreases the count in response to each clock pulse generated by theoscillator 730 until Vds increases above VTH_LOW. Conversely, as long asVds stays above VTH_HIGH, the controller 390 increases the count inresponse to each clock pulse generated by the oscillator 730 until Vdsdecreases below VTH_HIGH.

Based on the value of the up/down counter 720, the sensitivity of thedynamic auto-ranging current sense circuit 300 is adjusted 850. That is,based on the value of the up/down counter 720, the driver 330, the sensetransistor Msense 310, and the resistor 370 are controlled.

FIG. 8B is a flowchart illustrating a process for adjusting thesensitivity of the sense circuit when the count of the up/down counterdecreases, according to one embodiment. That is, FIG. 8 illustrates aprocess for adjusting the sensitivity of the sense circuit as theamplitude of the load current increases. In the embodiment of FIG. 8B,as the load current increases first the sense ratio between the maintransistor Mp 220 and the sense transistor Msense 310 is increased. Thatis, the sense transistor Msense 310 is controlled to decrease the sizeof the sense transistor Msense 310 (e.g., by reducing the number oftransistors that are active in the sense transistor Msense 310). Then,when the sense ratio reaches the maximum value, the resistance value ofthe sense resistor Rsense 370 is decreased. Finally, when the resistancevalue of the sense resistor Rsense 370 reaches the minimum value, thebias voltage Vbias provided by the driver 330 is increased. That is, thedriver 330 is controlled to increase the number of diode connectedtransistors that are active.

For instance, the controller 390 determines 862 whether the sense ratiobetween the main transistor Mp 220 and the sense transistor Msense 310is at a maximum value. If the sense ratio between the main transistor Mp220 and the sense transistor Msense 310 is not at a maximum value, thesense ratio between the main transistor Mp 220 and the sense transistorMsense 310 is increased 872. Otherwise, if the sense ratio between themain transistor Mp 220 and the sense transistor Msense 310 is at amaximum value, the controller 390 determines 864 whether the resistanceof the sense resistor Rsense 370 is at a minimum value. If theresistance of the sense resistor Rsense 370 is not at a minimum value,the resistance of the sense resistor Rsense 370 is decreased 874.Otherwise, if the resistance of the sense resistor Rsense 370 is at aminimum value, the controller 390 determines whether the bias voltageVbias provided by the driver 330 is at a maximum value. If the biasvoltage Vbias is not at a maximum value, the bias voltage Vbias isincreased 876.

FIG. 8C is a flowchart illustrating a process for adjusting thesensitivity of the sense circuit when the count of the up/down counterincreases, according to one embodiment. That is, FIG. 8 illustrates aprocess for adjusting the sensitivity of the sense circuit as theamplitude of the load current decreases. In the embodiment of FIG. 8C,as the load current decreases first the bias voltage Vbias is decreased.Then, when the bias voltage Vbias reaches the minimum value, theresistance of the sense resistor Rsense 370 is increased. Finally, whenthe resistance of the sense resistor Rsense 370 reaches the maximumvalue, the sense ratio between the main transistor Mp 220 and the sensetransistor Msense 310 is decreased.

For instance, the controller 390 determines 882 whether the bias voltageVbias provided by the driver 330 is at a minimum value. If the biasvoltage Vbias is not at a minimum value, the bias voltage Vbias isdecreased 892. Otherwise, if the bias voltage Vbias is at a minimumvalue, the controller 390 determines 884 whether the resistance of thesense resistor Rsense is at a maximum value. If the resistance of thesense resistor Rsense is not at a maximum value, the resistance of thesense resistor Rsense is increased 894. Otherwise, if the resistance ofthe sense resistor Rsense is at a maximum value, the controllerdetermines 886 whether the sense ratio between the main transistor Mp220 and the sense transistor Msense 310 is at a minimum value. If thesense ratio between the main transistor Mp 220 and the sense transistorMsense 310 is not at a minimum value, the sense ratio between the maintransistor Mp 220 and the sense transistor Msense 310 is decreased 896.

In other embodiments, the order in which the sense ratio, the biasvoltage Vbias and the resistance of the sense resistor Rsense areadjusted may be different from what is shown in FIGS. 8A and 8B.

Since the up/down discrete steps are changed in response to a loadcurrent range based on the voltage at the output of the drivingtransistor Mp 220, the sense current ratio and the sense resistor scalefactor can be controlled and are known. Therefore, a low-resolution ADCcan be used while maintaining the dynamic range of the dynamicauto-ranging current sense circuit 300.

While particular embodiments and applications have been illustrated anddescribed, it is to be understood that the invention is not limited tothe precise construction and components disclosed herein and thatvarious modifications, changes and variations which will be apparent tothose skilled in the art may be made in the arrangement, operation anddetails of the method and apparatus disclosed herein without departingfrom the spirit and scope of the present disclosure.

What is claimed is:
 1. A current sensing circuit comprising: a sensetransistor coupled to a main transistor that provides a load current,the sense transistor configured to generate a sensing currentproportional to the load current; a driver having an output terminalcoupled to the sense transistor, the driver configured to generate acontinuous bias voltage to bias the sense transistor and the maintransistor; a sense resistor coupled to the sense transistor; and acontroller circuit configured to generate a control signal forcontrolling at least one of a gain ratio of the sense transistor, aresistance of the sense resistor, and the bias voltage generated by thedriver, the controller comprising: a counter configured to modify avalue of the control signal in a first direction responsive to an outputvoltage of the main transistor becoming smaller than a first thresholdvoltage and configured to modify the value of the control signal in asecond direction responsive the output voltage of the main transistorbecoming larger than a second threshold voltage, the second directionopposite to the first direction.
 2. The current sensing circuit of claim1, wherein the output voltage of the main transistor is adrain-to-source voltage of the main transistor, wherein modifying thevalue of the control signal in the first direction comprises increasingthe value of the control signal, and wherein modifying the value of thecontrol signal in the second direction comprises decreasing the value ofthe control signal.
 3. The current sensing circuit of claim 1, whereinthe output voltage of the main transistor is a load voltage at an outputterminal of the main transistor, wherein modifying the value of thecontrol signal in the first direction comprises decreasing the value ofthe control signal, and wherein modifying the value of the controlsignal in the second direction comprises increasing the value of thecontrol signal.
 4. The current sensing circuit of claim 3, wherein thecontroller further comprises: a first comparator coupled to a firstinput of the counter, the first comparator configured to generate afirst counter signal responsive to the output voltage of the maintransistor becoming larger than the second threshold voltage; and asecond comparator coupled to a second input of the counter, the secondcomparator configured to generate a second counter signal responsive tothe output voltage of the main transistor becoming smaller than thefirst threshold voltage.
 5. The current sensing circuit of claim 4,wherein the counter is configured to increase the value of the controlsignal in response to receiving the first counter signal through thefirst input, and to decrease the value of the control signal in responseto receiving the second counter signal through the second input.
 6. Thecurrent sensing circuit of claim 4, wherein the controller circuitfurther comprises: a third comparator coupled to a third input of thecounter, the third comparator configured to generate a third countersignal responsive to the output voltage of the main transistor becomingsmaller than a third threshold voltage, wherein the counter isconfigured to reset in response to receiving the third counter signalthrough the third input.
 7. The current sensing circuit of claim 1,wherein the driver comprises: a current source configured to provide abias current; a first driver device coupled to the current source andconfigured to receive the bias current; a second driver device coupledto the first driver device and configured to receive at least part ofthe bias current; and a first switch coupled to a gate of the seconddriver device, the first switch configured to turn on or off the seconddriver device to control the bias voltage according to the value of thecontrol signal received from the controller circuit.
 8. The currentsensing circuit of claim 1, wherein the sense transistor comprises aplurality of individual devices which are selectively activated toadjust the gain ratio of the sense transistor, wherein the plurality ofindividual devices comprises: a first sensing device having a gateconnected to a first bias switch and a first bypass switch, the firstbias switch configured to couple the gate of the first sensing device tothe driver when the first bias switch is in a closed position; and asecond sensing device having a gate connected to a second bias switchand a second bypass switch, the second bias switch configured to couplethe gate of the second sensing device to the driver when the second biasswitch is in a closed position; wherein a gain ratio between the loadcurrent and sensing current is adjusted by controlling a number of biasswitches that are in a closed position.
 9. The current sensing circuitof claim 1, wherein the control signal comprises a first subset of bitsfor controlling the drive, a second subset of bits for controlling thesense resistor, and a third subset of bits for controlling the sensetransistor.
 10. A method for sensing a load current, comprising:generating, by a sense transistor, a sensing current, the sensetransistor coupled to a main transistor that provides the load current,the sensing current proportional to the load current; providing, by adriver, a continuous bias voltage to the sense transistor and the maintransistor to control the load current; generating, by a sense resistor,a sense voltage; monitoring a voltage at an output voltage of the maintransistor; and generating a control signal for controlling at least oneof a gain ratio of the sense transistor, a resistance of the senseresistor, and the bias voltage generated by the driver, wherein thecontrol signal is generated by: modifying the value of the controlsignal in a first direction responsive to the output voltage of the maintransistor becoming smaller than a first threshold voltage, andmodifying the value of the control signal in a second directionresponsive to the output voltage of the main transistor becoming largerthan a second threshold voltage, the second direction opposite to thefirst direction.
 11. The method of claim 10, wherein the output voltageof the main transistor is a drain-to-source voltage of the maintransistor, wherein modifying the value of the control signal in thefirst direction comprises increasing the value of the control signal,and wherein modifying the value of the control signal in the seconddirection comprises decreasing the value of the control signal.
 12. Themethod of claim 10, wherein the output voltage of the main transistor isa load voltage at an output terminal of the main transistor, whereinmodifying the value of the control signal in the first directioncomprises decreasing the value of the control signal, and whereinmodifying the value of the control signal in the second directioncomprises increasing the value of the control signal.
 13. The method ofclaim 12, further comprising: generating a first counter signal havingan active level in response to the output voltage of the main transistorbecoming larger than the second threshold voltage; and generating asecond counter signal having an active level in response to the outputvoltage of the main transistor becoming smaller than the first thresholdvoltage.
 14. The method of claim 13, wherein the value of the controlsignal is increased in response to generating the first counter signalhaving the active level, wherein the value of the control signal isdecreased in response to generating the second counter signal having theactive level.
 15. The method of claim 13, further comprising: generatinga third counter signal having an active level in response to the outputvoltage of the main transistor becoming smaller than a third thresholdvoltage; and resetting the value of the control signal in response togenerating the third counter having the third counter signal having theactive level.
 16. The method of claim 10, wherein the driver comprises acurrent source configured to provide a bias current, a first driverdevice coupled to the current source and configured to receive the biascurrent, a second driver device coupled to the first driver device andconfigured to receive at least part of the bias current, and a firstswitch configured to turn on or off the second driver device to controlthe bias voltage according to a control signal received from acontroller circuit, and wherein controlling the bias voltage generatedby the driver comprises opening the first switch to increase the biasvoltage.
 17. The method of claim 10, wherein the sense transistorcomprises a plurality of individual devices which are selectivelyactivated to adjust the gain ratio of the sense transistor, wherein theplurality of individual devices comprises a first sensing device havinga gate connected to a first bias switch and a first bypass switch, and asecond sensing device having a gate connected to a second bias switchand a second bypass switch, wherein controlling the gain ratio of thesense transistor comprises a number of bias switches that are in aclosed position.
 18. The method of claim 10, wherein the control signalcomprises a first subset of bits for controlling the drive, a secondsubset of bits for controlling the sense resistor, and a third subset ofbits for controlling the sense transistor.
 19. A controller circuit forcontrolling a sensing circuit, the sensing circuit for sensing an outputof a main transistor, the controller circuit comprising: a firstcomparator configured to generate a first counter signal responsive toan output voltage of the main transistor becoming smaller than a firstthreshold voltage; a second comparator configured to generate a secondcounter signal responsive to the output voltage of the main transistorbecoming larger than a second threshold voltage; and a counter having afirst input coupled to an output of the first comparator and a secondinput coupled to an output of the second comparator, the counterconfigured to modify a value of a control signal in a first directionresponsive receiving the first counter signal and configured to modifythe value of the control signal in a second direction responsivereceiving the second counter signal, the second direction opposite tothe first direction, the control signal for controlling at least one ofa gain ratio of a sense transistor of the sensing circuit, a resistanceof a sense resistor of the sensing circuit, and a continuous biasvoltage generated by a driver of the sensing circuit.
 20. The controllercircuit of claim 19, further comprising: a third comparator coupled to athird input of the counter, the third comparator configured to generatea third counter signal responsive to the output voltage of the maintransistor becoming smaller than a third threshold voltage, wherein thecounter is configured to reset in response to receiving the thirdcounter signal through the third input.